package zack.project.domain.activity.service.quota.policy.impl;

import zack.project.domain.activity.adapter.repository.IActivityRepository;
import zack.project.domain.activity.model.aggregate.CreateQuotaOrderAggregate;
import zack.project.domain.activity.model.valobj.OrderStateVO;
import zack.project.domain.activity.service.quota.policy.ITradePolicy;
import org.springframework.stereotype.Service;

/**
 * @author A1793
 */
@Service("credit_pay_trade")
public class CreditPayTradePolicy implements ITradePolicy {

    private final IActivityRepository activityRepository;

    public CreditPayTradePolicy(IActivityRepository activityRepository) {
        this.activityRepository = activityRepository;
    }

    /**
     * 需要支付的sku商品充值单需要在{raffle_activity_order}里面保存一笔待支付的记录
     * @param createQuotaOrderAggregate
     */
    @Override
    public void trade(CreateQuotaOrderAggregate createQuotaOrderAggregate) {
        createQuotaOrderAggregate.setOrderState(OrderStateVO.wait_pay);
        activityRepository.doSaveCreditPayOrder(createQuotaOrderAggregate);
    }
}
